from flask import Blueprint, jsonify, request
import json
from utils.db import db1
import time
bp_cate = Blueprint('cate', __name__)


@bp_cate.route('/cate', methods=['GET'])
def cate():
    if request.method == 'GET':
        sql1 = 'select * from cate'
        res = db1.findall(sql1)
        return jsonify({'code': 200, 'list': res})


@bp_cate.route('/caozuo', methods=['GET'])
def caozuo():
    if request.method == 'GET':
        id = int(request.args.get('id'))
        time.sleep(0.01)
        sql1 = 'select * from caozuo where cid = %d' % (id)
        res = db1.findall(sql1)
        return jsonify({'code': 200, 'list': res})
